home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / fpu881 / src6.zoo / asinh.c < prev    next >
C/C++ Source or Header  |  1991-09-24  |  2KB  |  99 lines

  1. /************************************************************************
  2.  *                                    *
  3.  *                N O T I C E                *
  4.  *                                    *
  5.  *            Copyright Abandoned, 1987, Fred Fish        *
  6.  *                                    *
  7.  *    This previously copyrighted work has been placed into the    *
  8.  *    public domain by the author (Fred Fish) and may be freely used    *
  9.  *    for any purpose, private or commercial.  I would appreciate    *
  10.  *    it, as a courtesy, if this notice is left in all copies and    *
  11.  *    derivative works.  Thank you, and enjoy...            *
  12.  *                                    *
  13.  *    The author makes no warranty of any kind with respect to this    *
  14.  *    product and explicitly disclaims any implied warranties of    *
  15.  *    merchantability or fitness for any particular purpose.        *
  16.  *                                    *
  17.  ************************************************************************
  18.  */
  19.  
  20.  
  21. /*
  22.  *  FUNCTION
  23.  *
  24.  *    asinh   double precision hyperbolic arc sine
  25.  *
  26.  *  KEY WORDS
  27.  *
  28.  *    asinh
  29.  *    machine independent routines
  30.  *    math libraries
  31.  *
  32.  *  DESCRIPTION
  33.  *
  34.  *    Returns double precision hyperbolic arc sine of double precision
  35.  *    floating point number.
  36.  *
  37.  *  USAGE
  38.  *
  39.  *    double asinh (x)
  40.  *    double x;
  41.  *
  42.  *  RESTRICTIONS
  43.  *
  44.  *    The domain of the ASINH function is the entire real axis
  45.  *    however the evaluation of x squared may cause overflow
  46.  *    for large magnitudes.
  47.  *
  48.  *    For precision information refer to documentation of the
  49.  *    floating point library routines called.
  50.  *    
  51.  *  PROGRAMMER
  52.  *
  53.  *    Fred Fish
  54.  *
  55.  *  INTERNALS
  56.  *
  57.  *    Computes asinh(x) from:
  58.  *
  59.  *        1.    Let xmax = sqrt(MAXDOUBLE - 1)
  60.  *            
  61.  *        2.    If x < -xmax or xmax < x then
  62.  *            let x = xmax and flag overflow.
  63.  *
  64.  *        3.    asinh(x) = log [x+sqrt(x**2 + 1)]
  65.  *
  66.  */
  67.  
  68. #include <stdio.h>
  69. #include <pmluser.h>
  70. #include "pml.h"
  71.  
  72. static char funcname[] = "asinh";
  73.  
  74.  
  75. double asinh (x)
  76. double x;
  77. {
  78.     auto struct exception xcpt;
  79.     extern double log ();
  80.     extern double sqrt ();
  81.  
  82.     DBUG_ENTER (funcname);
  83.     DBUG_3 ("asinhin", "arg %le", x);
  84.     if (x < -SQRT_MAXDOUBLE || x > SQRT_MAXDOUBLE) {
  85.     xcpt.type = OVERFLOW;
  86.     xcpt.name = funcname;
  87.     xcpt.arg1 = x;
  88.     if (!matherr (&xcpt)) {
  89.         fprintf (stderr, "%s: OVERFLOW error\n", funcname);
  90.         errno = ERANGE;
  91.         xcpt.retval = log (2 * SQRT_MAXDOUBLE);
  92.     }
  93.     } else {
  94.     xcpt.retval = log (x + sqrt(x*x + 1.0));
  95.     }
  96.     DBUG_3 ("asinhout", "result %le", xcpt.retval);
  97.     DBUG_RETURN (xcpt.retval);
  98. }
  99.